/*
    OpenLib
    Copyright (C) 2011  Michael Gukov

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

function CreatePanel() {
    var page_count, curr_page, visible_pages, pref;
    if (page_count > 1) {
        var P = parseInt(curr_page);
        var media = Math.floor(visible_pages / 2);
        var SP, FP;

        if (visible_pages >= page_count) {
            SP = 1;
            FP = page_count;
        } else if (P - media <= 1) {
            SP = 1;
            FP = visible_pages;
        } else if (P + media >= page_count) {
            FP = page_count;
            SP = FP - visible_pages + 1;
        } else {
            SP = P - media;
            FP = SP + visible_pages - 1;
        }
        var panel, cases = [];
        for (var i = SP; i <= FP; ++i) {
            if (i == P) {
                cases.push({tag: "span", body: [{text: i}],
                    attr: {id: "SelectPage", "class": "SelectPage", "data-p": i}
                });
            } else {
                cases.push({tag: "a",
                    body: [{text: (((i == SP && i > 1) || (i == FP && i < page_count)) ? "..." : i)}],
                    attr: {
                        id: pref + "P" + i,
                        "class": "PageLink",
                        "data-p": i,
                        href: i
                    }
                });
            }
        }
        panel = {tag: "div", body: cases,
            attr: {id: pref + "PagePanel", "class": "PagePanel"}
        };
        jsun.dom.by_id(pref + "PageSwitch")
            .appendChild(jsun.dom.from_json(panel));
    }
}

document.getElementById(elementId).on


list.options.cloneNode(1).on;

var a = "sdsdsdfsdf"

this.parentNode.replaceChild(this, this.cloneNode(1));